function timinstemicalc(age, rf, cad, asa, angina, stc, ecm){

var timiscore=0;
var mortality ="";

if (age){age=1;}else{age=0;}
if (rf){rf=1;}else{rf=0;}
if (cad){cad=1;}else{cad=0;}
if (asa){asa=1;}else{asa=0;}
if (angina){angina=1;}else{angina=0;}
if (stc){stc=1;}else{stc=0;}
if (ecm){ecm=1;}else{ecm=0;}

timiscore= age + rf + cad + asa + angina + stc + ecm;


if (timiscore <= 1) {mortality = "5% risk at 14 days of: <br />all-cause mortality, new or recurrent MI, or severe recurrent ischemia requiring urgent revascularization.";}
if (timiscore ==2) {mortality = "8% risk at 14 days of: <br />all-cause mortality, new or recurrent MI, or severe recurrent ischemia requiring urgent revascularization.";}
if (timiscore ==3){mortality = "13% risk at 14 days of: <br />all-cause mortality, new or recurrent MI, or severe recurrent ischemia requiring urgent revascularization.";}
if (timiscore ==4) {mortality = "20% risk at 14 days of: <br />all-cause mortality, new or recurrent MI, or severe recurrent ischemia requiring urgent revascularization.";}
if (timiscore ==5) {mortality = "26% risk at 14 days of: <br />all-cause mortality, new or recurrent MI, or severe recurrent ischemia requiring urgent revascularization.";}
if (timiscore > 5) {mortality = "41% risk at 14 days of: <br />all-cause mortality, new or recurrent MI, or severe recurrent ischemia requiring urgent revascularization.";}




return {
			 timiscore:timiscore,
			 mortality:mortality
	};		 
}


var def1="<strong>Risk factors for CAD :</strong><ul><li>Family history of CAD</li><li>Hypertension</li><li>Hypercholesterolemia</li><li>Diabetes</li><li>Current Smoker</li></ul>";
var def2="<strong>Elevated Cardiac markers:</strong> <br />CK MB and/or cardiac specific troponin level";




function ref(){
// display reference
 return "Antman et al. The TIMI Risk Score for Unstable Angina/Non-ST Elevation MI <a href='http://jama.ama-assn.org/cgi/content/abstract/284/7/835'>JAMA. 2000;284:835-842</a>";
}

function help() {
	return def1+def2;
}
